/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SalesManager.java
 *
 * Created on Mar 30, 2011, 4:47:03 PM
 */
package inventorymanagement;

import model.ColorTable;
import DataAccess.DBUtil;
import DataAccess.TableAccess;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Viet Anh
 */
public class SalesManager extends javax.swing.JFrame {

    String date;
    Date dt;
    final SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy");
    Connection conn = DBUtil.getConnection(DBUtil.getInfoDB());

    /** Creates new form SalesManager */
    public SalesManager() {
        initComponents();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation(((int) screenSize.getWidth() - this.getWidth()) / 2,
                ((int) screenSize.getHeight() - this.getHeight()) / 2);
        btnBillCancel.setEnabled(false);
        btnMoney.setEnabled(false);
        btnReturn.setEnabled(false);
        btnTotalBill.setEnabled(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tblDetail = new ColorTable();
        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        btnDayChooser = new javax.swing.JButton();
        btnReturn = new javax.swing.JButton();
        btnBillCancel = new javax.swing.JButton();
        btnTotalBill = new javax.swing.JButton();
        btnMoney = new javax.swing.JButton();
        txtBillCancel = new javax.swing.JTextField();
        txtItemReturn = new javax.swing.JTextField();
        lblTotalBill = new javax.swing.JLabel();
        dchDayChooser = new com.toedter.calendar.JDateChooser("MM/dd/yyyy", "##/##/####", '_');
        txtMoney = new javax.swing.JTextField();
        lblItemReturn = new javax.swing.JLabel();
        lblBillCancel = new javax.swing.JLabel();
        lblMoney = new javax.swing.JLabel();
        txtTotalBill = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        btnRefresh = new javax.swing.JButton();
        btnClose = new javax.swing.JButton();
        lblTableDetail = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        tblDetail.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(tblDetail);

        jPanel1.setBackground(new java.awt.Color(0, 153, 153));

        jLabel5.setFont(new java.awt.Font("Times New Roman", 0, 36));
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Sales Manager");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(165, 165, 165)
                .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(217, 217, 217))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Sales Manager"));

        btnDayChooser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/ok.png"))); // NOI18N
        btnDayChooser.setText("View");
        btnDayChooser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDayChooserActionPerformed(evt);
            }
        });

        btnReturn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/report.png"))); // NOI18N
        btnReturn.setText("Detail");
        btnReturn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReturnActionPerformed(evt);
            }
        });

        btnBillCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/report.png"))); // NOI18N
        btnBillCancel.setText("Detail");
        btnBillCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBillCancelActionPerformed(evt);
            }
        });

        btnTotalBill.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/report.png"))); // NOI18N
        btnTotalBill.setText("Detail");
        btnTotalBill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTotalBillActionPerformed(evt);
            }
        });

        btnMoney.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/report.png"))); // NOI18N
        btnMoney.setText("Detail");
        btnMoney.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMoneyActionPerformed(evt);
            }
        });

        txtBillCancel.setEditable(false);

        txtItemReturn.setEditable(false);

        lblTotalBill.setText("Total bill in day:");

        dchDayChooser.setMaxSelectableDate(new java.util.Date(253370743308000L));
        dchDayChooser.setMinSelectableDate(new java.util.Date(-62135791092000L));
        dchDayChooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                dchDayChooserPropertyChange(evt);
            }
        });

        txtMoney.setEditable(false);

        lblItemReturn.setText("Total item return in day:");

        lblBillCancel.setText("Bill cancel in day:");

        lblMoney.setText("Total money in day:");

        txtTotalBill.setEditable(false);

        jLabel3.setText("Choose day:");

        btnRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Refresh.png"))); // NOI18N
        btnRefresh.setText("Refresh");
        btnRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefreshActionPerformed(evt);
            }
        });

        btnClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/cancel.png"))); // NOI18N
        btnClose.setText("Close");
        btnClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(lblMoney, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                                    .addComponent(lblItemReturn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                                    .addComponent(lblBillCancel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                                    .addComponent(lblTotalBill, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE))
                                .addGap(10, 10, 10)))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtItemReturn)
                            .addComponent(txtBillCancel)
                            .addComponent(txtMoney)
                            .addComponent(txtTotalBill)
                            .addComponent(dchDayChooser, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE))
                        .addGap(35, 35, 35)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(btnReturn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnBillCancel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnMoney, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnTotalBill, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnDayChooser, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGap(304, 304, 304)
                        .addComponent(btnRefresh, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnClose, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnDayChooser)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel3)
                        .addComponent(dchDayChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTotalBill, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblTotalBill)
                    .addComponent(btnTotalBill))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtMoney, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblMoney)
                    .addComponent(btnMoney))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtBillCancel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblBillCancel)
                    .addComponent(btnBillCancel))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtItemReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblItemReturn)
                    .addComponent(btnReturn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnRefresh)
                    .addComponent(btnClose)))
        );

        lblTableDetail.setText("Table Detail:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblTableDetail)
                .addContainerGap(522, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblTableDetail)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnReturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReturnActionPerformed
        // TODO add your handling code here:
        date = "";
        dt = dchDayChooser.getDate();

        try {
            date = SDF.format(dt).toString();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Date null");
            dchDayChooser.requestFocus();
            return;
        }
        lblTableDetail.setText("Item return in " + date + ":");
        String sql = "SELECT BillSellDetails.BillID, ItemName, QuantityReceipt AS ItemReturn, Date FROM BillSellDetails"
                + " INNER JOIN Receipt ON BillSellDetails.BillID = Receipt.BillID"
                + " INNER JOIN Items ON BillSellDetails.ItemID = Items.ItemID"
                + " WHERE Receipt.Date = '" + date + "' AND Receipt.Accept = 1 AND QuantityReceipt > 0";
        TableAccess.readToTable(sql, tblDetail);
    }//GEN-LAST:event_btnReturnActionPerformed

    private void btnTotalBillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTotalBillActionPerformed
        // TODO add your handling code here:
        date = "";
        dt = dchDayChooser.getDate();

        try {
            date = SDF.format(dt).toString();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Date null");
            dchDayChooser.requestFocus();
            return;
        }
        lblTableDetail.setText("Bill in " + date + ":");
        String sql = "SELECT * FROM BILLS WHERE DATE ='" + date + "'";
        TableAccess.readToTable(sql, tblDetail);
    }//GEN-LAST:event_btnTotalBillActionPerformed

    private void btnMoneyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoneyActionPerformed
        // TODO add your handling code here:
        date = "";
        dt = dchDayChooser.getDate();
        try {
            date = SDF.format(dt).toString();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Date null");
            dchDayChooser.requestFocus();
            return;
        }
        lblTableDetail.setText("Money in " + date + ":");
        String sql = "SELECT BillSellDetails.BillID, ItemName,"
                + " (Quantity - QuantityReceipt) AS Quantity,"
                + " Discount, Price,"
                + " ((Quantity - QuantityReceipt)*Price - (Quantity - QuantityReceipt)*Price*Discount/100)"
                + " AS TOTAL FROM BillSellDetails"
                + " INNER JOIN Bills ON BillSellDetails.BillID = Bills.BillID"
                + " INNER JOIN Items ON BillSellDetails.ItemID = Items.ItemID"
                + " WHERE Bills.Date = '" + date + "' AND Bills.Status = 1";
        TableAccess.readToTable(sql, tblDetail);
    }//GEN-LAST:event_btnMoneyActionPerformed

    private void btnBillCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBillCancelActionPerformed
        // TODO add your handling code here:
        date = "";
        dt = dchDayChooser.getDate();
        try {
            date = SDF.format(dt).toString();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Date null");
            dchDayChooser.requestFocus();
            return;
        }
        lblTableDetail.setText("Bill cancel in " + date + ":");
        String sql = "SELECT * FROM BILLS WHERE BILLS.Status = 0 AND DATE ='" + date + "'";
        TableAccess.readToTable(sql, tblDetail);
    }//GEN-LAST:event_btnBillCancelActionPerformed

    private void btnDayChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDayChooserActionPerformed
        // TODO add your handling code here:

        date = "";
        int countTotalBill = 0;
        float countMoney = 0;
        int countBillCancel = 0;
        int countItemReturn = 0;
        dt = dchDayChooser.getDate();
        try {
            date = SDF.format(dt).toString();
            btnBillCancel.setEnabled(true);
            btnMoney.setEnabled(true);
            btnReturn.setEnabled(true);
            btnTotalBill.setEnabled(true);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Date null");
            dchDayChooser.requestFocus();
            return;
        }
        try {
            Statement st = conn.createStatement();
            String sql1 = "SELECT COUNT(*) FROM BILLS WHERE DATE ='" + date + "'";
            ResultSet rs = st.executeQuery(sql1);
            while (rs.next()) {
                countTotalBill = rs.getInt(1);
            }
            lblTotalBill.setText("Total Bill in " + date + ":");
            txtTotalBill.setText(String.valueOf(countTotalBill));

            String sql2 = "SELECT (Quantity - QuantityReceipt) AS Quantity,"
                    + " Discount, Price FROM BillSellDetails"
                    + " INNER JOIN Bills ON BillSellDetails.BillID = Bills.BillID"
                    + " INNER JOIN Items ON BillSellDetails.ItemID = Items.ItemID"
                    + " WHERE Bills.Date = '" + date + "' AND Bills.Status = 1";
            rs = st.executeQuery(sql2);
            while (rs.next()) {
                int quantity = rs.getInt("Quantity");
                float price = rs.getFloat("Price");
                float discount = rs.getFloat("Discount");
                countMoney += (quantity * price) - (quantity * price) * discount / 100;
            }
            lblMoney.setText("Total money in " + date + ":");
            txtMoney.setText(String.valueOf(countMoney));

            String sql3 = "SELECT COUNT(*) FROM BILLS WHERE BILLS.Status = 0 AND DATE ='" + date + "'";
            rs = st.executeQuery(sql3);
            while (rs.next()) {
                countBillCancel = rs.getInt(1);
            }
            lblBillCancel.setText("Bill Cancel in " + date + ":");
            txtBillCancel.setText(String.valueOf(countBillCancel));

            String sql4 = "SELECT SUM(QuantityReceipt) FROM BillSellDetails"
                    + " INNER JOIN Receipt ON BillSellDetails.BillID = Receipt.BillID"
                    + " WHERE Receipt.Date = '" + date + "' AND Receipt.Accept = 1";
            rs = st.executeQuery(sql4);
            while (rs.next()) {
                countItemReturn = rs.getInt(1);
            }
            lblItemReturn.setText("Total item return in " + date + ":");
            txtItemReturn.setText(String.valueOf(countItemReturn));

        } catch (Exception e) {
        }

    }//GEN-LAST:event_btnDayChooserActionPerformed

    private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshActionPerformed
        // TODO add your handling code here:
        dchDayChooser.setDate(null);
        lblBillCancel.setText("Bill cancel in day:");
        lblItemReturn.setText("Total item return in day:");
        lblMoney.setText("Total money in day:");
        lblTableDetail.setText("Table detail:");
        lblTotalBill.setText("Total bill in day:");
        txtBillCancel.setText(null);
        txtItemReturn.setText(null);
        txtMoney.setText(null);
        txtTotalBill.setText(null);
        btnBillCancel.setEnabled(false);
        btnMoney.setEnabled(false);
        btnReturn.setEnabled(false);
        btnTotalBill.setEnabled(false);
        DefaultTableModel dtm = (DefaultTableModel) tblDetail.getModel();
        for (int i = dtm.getRowCount() - 1; i >= 0; i--) {
                dtm.removeRow(i);
            }
        for (int i = dtm.getColumnCount() - 1; i >= 0; i--) {
                tblDetail.removeColumn(tblDetail.getColumnModel().getColumn(i));
            }
        
    }//GEN-LAST:event_btnRefreshActionPerformed

    private void dchDayChooserPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_dchDayChooserPropertyChange
        // TODO add your handling code here:
        btnBillCancel.setEnabled(false);
        btnMoney.setEnabled(false);
        btnReturn.setEnabled(false);
        btnTotalBill.setEnabled(false);
    }//GEN-LAST:event_dchDayChooserPropertyChange

    private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_btnCloseActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new SalesManager().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBillCancel;
    private javax.swing.JButton btnClose;
    private javax.swing.JButton btnDayChooser;
    private javax.swing.JButton btnMoney;
    private javax.swing.JButton btnRefresh;
    private javax.swing.JButton btnReturn;
    private javax.swing.JButton btnTotalBill;
    private com.toedter.calendar.JDateChooser dchDayChooser;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblBillCancel;
    private javax.swing.JLabel lblItemReturn;
    private javax.swing.JLabel lblMoney;
    private javax.swing.JLabel lblTableDetail;
    private javax.swing.JLabel lblTotalBill;
    private javax.swing.JTable tblDetail;
    private javax.swing.JTextField txtBillCancel;
    private javax.swing.JTextField txtItemReturn;
    private javax.swing.JTextField txtMoney;
    private javax.swing.JTextField txtTotalBill;
    // End of variables declaration//GEN-END:variables
}
